home *** CD-ROM | disk | FTP | other *** search
- /* view.c - View program - main function */
- #include "stdio.h"
- #include "cminor.h"
- #include "viewcmds.h"
- #include "viewparm.h"
-
- char filename[65] = "" ;
-
- main(argc,argv)
- int argc ;
- char *argv[] ;
- {
- int cmd ; /* holds current cmd */
-
- if( argc <= 2 ) /* get file name from command */
- strcpy(filename,argv[1]) ; /* line (if present) */
-
- get_filename(filename) ; /* get file name and open file */
- set_filesize(ASC_MODE) ; /* set up file size variable */
- cmd = FIRSTPAGE ; /* force display of first page */
-
- while( cmd != EXITPGM ) /* repeat until told to exit */
- { exec_cmd(cmd) ; /* execute the current command */
- cmd = get_cmd() ; /* get the next command */
- }
-
- close_file() ;
- }
-
- int get_filename(fn) /* get name of file and open it */
- char fn[] ; /* file name string */
- { /* filled out by caller */
- if( strlen(fn) == 0 )
- { printf("File Name:") ;
- scanf("%s",fn) ;
- }
-
- while( open_file(fn) == FAILURE ) /* open the file (verify name) */
- { printf("\n File - %s can not be opened\n",fn) ;
- printf("File Name:") ; /* try again */
- scanf("%s",fn) ;
- }
- }
-
-
-